﻿using System.Linq;
using System.Net;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.ServiceModel.Activation;
using Ashlen.Portal.Core;
using Ashlen.Portal.Core.DTO;
using Ashlen.Portal.Core.DataInterfaces;
using Ashlen.Portal.Data;
using System.Web;
using System.Web.Security;
using System.Web.Mvc;
using System.Web.Caching;

namespace Ashlen.Portal.Services
{
    public class ServiceBase
    {
        protected void SetCache()
        {
            OutgoingWebResponseContext Response = WebOperationContext.Current.OutgoingResponse;
            HttpResponseHeader cacheHeader = HttpResponseHeader.CacheControl;
            string cacheControlValue = string.Format("max-age={0}, must-revalidate", 1000);
            Response.Headers.Add(cacheHeader, cacheControlValue);
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
        }

        protected void SetCache(int cacheTimeout)
        {
            OutgoingWebResponseContext Response = WebOperationContext.Current.OutgoingResponse;
            HttpResponseHeader cacheHeader = HttpResponseHeader.CacheControl;
            string cacheControlValue = string.Format("max-age={0}, must-revalidate", cacheTimeout);
            Response.Headers.Add(cacheHeader, cacheControlValue);
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
        }
    }
}